// 熟悉属性管理模块的接口
/*品牌管理文件接口 */
import request from '@/utils/request.js'
import { CategoryResponseData, AttrResponseData } from './type.js'
enum API {
  // 获取一级分类的接口
  C1_URL = '/admin/product/getCategory1',
  // 获取二级分类的接口
  C2_URL = '/admin/product/getCategory2/',
  // 获取三级分类的接口
  C3_URL = '/admin/product/getCategory3/',
  // 获取分类下已有的属性和属性值
  ATTR_URL = '/admin/product/attrInfoList/',
  // 添加或者修改分类属性
  ADD_OR_UPDATA_ATTR_URL = '/admin/product/saveAttrInfo',
  DELATTR_URL = '/admin/product/deleteAttr/'
}

export const reqC1 = () => request.get<any, CategoryResponseData>(API.C1_URL)
export const reqC2 = (Category1ID: number | string) =>
  request.get<any, CategoryResponseData>(API.C2_URL + Category1ID)
export const reqC3 = (Category2ID: number | string) =>
  request.get<any, CategoryResponseData>(API.C3_URL + Category2ID)
export const reqAttr = (
  Category1ID: number | string,
  Category2ID: number | string,
  Category3ID: number | string
) =>
  request.get<any, AttrResponseData>(API.ATTR_URL + `${Category1ID}/${Category2ID}/${Category3ID}`)
export const reqAddOrUpdataAttr = (data: Attr) =>
  request.post<any, CategoryResponseData>(API.ADD_OR_UPDATA_ATTR_URL, data)

export const reqDelDataAttr = (attrId: number) =>
  request.delete<any, CategoryResponseData>(API.DELATTR_URL + attrId)
